/**
 * Create in 2012-10-12 下午9:00:00.
 */
package kit4j.app.notepad.ui.comp;

import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.TrayIcon;

import kit4j.app.notepad.command.NotepadCommandExecutor;
import kit4j.app.notepad.config.NotepadConfig;
import kit4j.app.notepad.ui.menu.CreateNewNotepadMenuItem;
import kit4j.app.notepad.ui.menu.ExitMenuItem;
import kit4j.app.notepad.ui.menu.NotepadsMenu;

import com.google.inject.Inject;

/**
 * 
 * @author MiniKnife
 *
 */
public class NotepadTrayIcon extends TrayIcon {

	@Inject
	public NotepadTrayIcon(NotepadConfig config, NotepadCommandExecutor commandExecutor) {
		super(config.getImage("TRAY_ICON.IMAGE_FILE_NAME"), config.getString("TRAY_ICON.TOOLTIP", "kit4j Notepad by MiniKnife"));
		setImageAutoSize(true);
		initMenu(config, commandExecutor);
	}
	
	private void initMenu(NotepadConfig config, NotepadCommandExecutor commandExecutor) {
		PopupMenu menu = new PopupMenu();
		MenuItem newItem = new CreateNewNotepadMenuItem(config, commandExecutor);
		MenuItem notepadsMenu = new NotepadsMenu(config, commandExecutor);
		MenuItem exitItem = new ExitMenuItem(config, commandExecutor);
		
		menu.add(newItem);
		menu.add(notepadsMenu);
		menu.add(exitItem);
		
		setPopupMenu(menu);
	}

}
